import numpy as np
import pandas as pd
import os
import sys
import pickle
from joblib import dump, load
import yaml
import statsmodels.api as sm
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import RandomizedSearchCV
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.linear_model import LinearRegression as reg
import pdb
from pprint import pprint
from statistics import mean
import random
random.seed(50)
import math
import argparse

sys.path.insert(1,'/REDACTED/fairness/code/rf/scripts/rf')
import tune_utils as tu
from gpd_test import *

###############################################
#### Hyperparameter Tuning
###############################################


sys.path.insert(1,'/REDACTED/fairness/code/rf/scripts/rf')
import tune_utils as tu

### get train and test data for each fold
tu.k_fold_split(random_state=50,
                 n_splits=5,
                 eitc=True,
                 dep_database=True,
                 datapath='/REDACTED/fairness/code/rf/data/')

####HYPERPARAMTER TUNING - Do this on separate TMUX windows in parallel
#### instead of in loop like below

### Hyperparatmer tuning - regressor
for fold in range(5):
        tu.tune_model(train_fold=fold, 
                eitc=True,
                dep_database=True,
                datapath='/REDACTED/fairness/code/rf/data/',
                model_type= 'reg', ## options are 'reg', 'cls'
                threshold= None, ## options (for now) are None or 100
                ts=0.25, ## test size
                cvs=5,
                njs=10)

### Hyperparatmer tuning - classifier
thresh_list = [1,50,100,500,1000, 2000]
for thresh in thresh_list:
        for fold in range(5):
                tu.tune_model(train_fold=fold, 
                 eitc=True,
                 dep_database=True,
                 datapath='/REDACTED/fairness/code/rf/data/',
                 model_type= 'reg', ## options are 'reg', 'cls'
                 threshold= thresh, ## options (for now) are None or 100
                 ts=0.25, ## test size
                 cvs=5,
                 njs=10)